home *** CD-ROM | disk | FTP | other *** search
/ Chip: Special XP & Vista / Chip Spesial XP & Vista.iso / 3_Gadgets / Yahoo_Mail / YahooMail.gadget / js / gadget.js
Text File  |  2007-11-27  |  5KB  |  168 lines

  1. // JavaScript Document
  2. ///////////////////
  3. /////SidebarGadgets.biz constants
  4. //////////////////
  5.  
  6. var gSearchURL = new Array("http://mail.yahoo.com", "http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=goldboxdeals-20&linkCode=ur2&camp=1789&creative=9325", "http://rover.ebay.com/rover/1/711-1751-2978-3/1?aid=5902069&pid=2552472", "http://rover.ebay.com/rover/1/710-5232-2978-16/1?aid=5048476&pid=2552472", "http://www.facebook.com", "http://www.joecartoon.com", "http://www.dpbolvw.net/click-2552472-10489289", "http://www.tkqlhce.com/click-2552472-10476826", "http://www.myspace.com/musicdownloadmusic", "http://www.dpbolvw.net/click-2552472-10386813", "http://www.anrdoezrs.net/click-2389807-10421372", "http://wikipedia.org", "http://www.youtube.com");
  7. var gSearchName = new Array("Yahoo Mail", "Amazon", "eBay", "eBay UK", "Facebook", "Joe Cartoon", "Lavalife", "Metaboli", "Myspace", "Starbucks", "WestJet", "Wikipedia", "YouTube");
  8. //var gSearchURL ="http://mail.yahoo.com";
  9. //var gSearchURL = new Array("", "http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=goldboxdeals-20&linkCode=ur2&camp=1789&creative=9325", "http://rover.ebay.com/rover/1/711-1751-2978-3/1?aid=5902069&pid=2552472", "", "", "", "", "", "", "");
  10. //var gSearchName = new Array("Yahoo Mail", "Amazon", "eBay", "", "", "", "", "", "", "");
  11.  
  12. //sample 
  13. //http://www.sidebargadgets.biz
  14. ////////////////////////
  15. //////Debug
  16. /////////////////
  17. function Debug(string)
  18. {
  19.     System.Debug.outputString(string);
  20. }
  21. ///////////////////////////////
  22. // Handlers for gadget's events
  23. //////////////////////////////
  24.  
  25. function SettingsClosed(event)
  26. {
  27.     if (event.closeAction == event.Action.commit)
  28.     {
  29.         loadGadget();
  30.     }    
  31. }
  32.                                                              
  33. function SettingsClosing(event)
  34. {
  35.     if (event.closeAction == event.Action.commit)
  36.     {
  37.         SaveSettings();
  38.     }  
  39.     else if (event.closeAction == event.Action.cancel)
  40.     {
  41.     }
  42.     event.cancel = false;
  43. }
  44.  
  45. function CheckDockState()
  46. {
  47.     if (System.Gadget.docked)
  48.     {
  49.         //set dock state
  50.         dockedState();
  51.     }
  52.     else
  53.     {
  54.         //set undock state
  55.         undockedState();
  56.     }
  57. }
  58.  
  59. /////////////////////////////
  60. ///////Gadgets functions
  61. //////////////////////////
  62. //load gadget function
  63. function loadGadget()
  64. {
  65.     Start();
  66.     if (typeof (System) == 'undefined') return;
  67.     //attach to events
  68.     System.Gadget.onSettingsClosed = SettingsClosed;
  69.     System.Gadget.onDock = CheckDockState;
  70.     System.Gadget.onUndock = CheckDockState;
  71. //    System.Gadget.settingsUI = "settings.html";
  72. }
  73. //event undocked
  74. function undockedState()
  75. {
  76.     Debug("Undocked State");
  77. }
  78. //event docked
  79. function dockedState()
  80. {   
  81.     Debug("docked State");
  82. }
  83.  
  84. /////////////////////////////
  85. /////Settings functions
  86. ///////////////////////////
  87.  
  88. //load settings function
  89. function loadSettings()
  90. {   Debug("Load settings");
  91.     if (typeof (System) == 'undefined') return;
  92.     System.Gadget.onSettingsClosing = SettingsClosing;
  93.     if (System.Gadget.Settings.read("first_time")=="")
  94.     {
  95. Debug("1000");
  96.         gad_time.value = gDefaultTime;
  97.     }
  98.     else
  99.     {       Debug("00");
  100.         var gTime = System.Gadget.Settings.read("gad_time");
  101.         if (gTime == "") gad_time.value = gDefaultTime;
  102.         else gad_time.value = gTime;
  103.     }
  104. }
  105. //save settings function
  106. function SaveSettings()
  107. {
  108.     System.Gadget.Settings.write("gad_time", gad_time.value);
  109.     System.Gadget.Settings.write("first_time", "no");
  110. }
  111.  
  112. ///////////////////////
  113. ////Gadget custom code
  114. ///////////////////////
  115. function Start()
  116. {
  117.     var myselect = document.getElementById("engine");
  118.     var j=0;
  119.     for(var i=0; i<13; i++)
  120.     {
  121.         if(gSearchName[i]!="")
  122.         {
  123.             myselect.options[j] = new Option(gSearchName[i],i);
  124.             j++;
  125.         }
  126.     }
  127.     myselect.selectedIndex=0;
  128.     var myeng = document.getElementById("eng");
  129.     myeng.value=myselect.options[0].text;
  130. }
  131.  
  132. function Search(keyword)
  133. {
  134.     var myselect = document.getElementById("engine");
  135.     if(myselect.selectedIndex != -1)
  136.     {
  137.         //replace %keyword
  138.         var str=gSearchURL[myselect.options[myselect.selectedIndex].value].replace("%keyword%", document.getElementById("keyword").value);
  139. //        alert(str);
  140.         location.href=str;
  141.     }
  142. }
  143.  
  144. function Show()
  145. {
  146.     var mydiv = document.getElementById("select_box");
  147.     mydiv.style.display = (mydiv.style.display=='none')?'':'none'; 
  148.     return false;
  149. }
  150.  
  151. function Select()
  152. {
  153.     var myselect = document.getElementById("engine");
  154.     var myeng = document.getElementById("eng");
  155.     myeng.value=myselect.options[myselect.selectedIndex].text;
  156.     var mydiv = document.getElementById("select_box");
  157.     mydiv.style.display = 'none'; 
  158. }
  159.  
  160. function handleKeyPress(e,form)
  161. {
  162.     var key=e.keyCode || e.which;
  163.     if (key==13)
  164.     {
  165.         Search();
  166.     }
  167. }
  168.